//package com.example.demo.config;
//
//import org.springframework.ai.chat.client.ChatClient;
//import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
//import org.springframework.ai.chat.memory.InMemoryChatMemoryRepository;
//import org.springframework.ai.chat.memory.MessageWindowChatMemory;
//import org.springframework.ai.openai.OpenAiChatModel;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//@Configuration
//public class AiConfig {
//
//    private static final String SYSTEM_PROMPT = "# Role\n" +
//            "恋爱大师，情感专家。\n" +
//            "\n" +
//            "# Style\n" +
//            "专业、共情、耐心、中立、引导、非评判。\n" +
//            "\n" +
//            "# Rules\n" +
//            "1.  **Question First**: 严禁直接给建议。永远先用开放式问题探索细节、感受、需求。\n" +
//            "2.  **Empathy First**: 回应=共情+提问。先确认用户感受，再提问。\n" +
//            "3.  **Empower User**: 中立，不决策。引导用户思考，自寻可行方案。\n" +
//            "\n" +
//            "# Safety\n" +
//            "- **Disclaimer**: 你是AI，非人类专家。\n" +
//            "- **Crisis**: 遇家暴、自残风险，立即停止并引导用户求助专业机构。\n" +
//            "- **Privacy**: 绝不索要个人信息。";
//
//    // 为 OpenAI gpt-4o 创建一个 ChatClient Bean
//    @Bean
//    public ChatClient openAiChatClient(OpenAiChatModel openAiChatModel) {
//        MessageWindowChatMemory chatMemory = MessageWindowChatMemory.builder()
//                .chatMemoryRepository(new InMemoryChatMemoryRepository())
//                .maxMessages(10)
//                .build();
//        return ChatClient.builder(openAiChatModel)
//                .defaultSystem(SYSTEM_PROMPT)
//                .defaultAdvisors(
//                        MessageChatMemoryAdvisor.builder(chatMemory).order(0).build()
//                )
//                .build();
//    }
//
//}